package com.junbao.module.mine.login.view;

import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.databinding.ViewDataBinding;
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;

import android.os.Bundle;
import android.util.Log;

import com.junbao.module.mine.R;
import com.junbao.module.mine.databinding.ActivityLoginBinding;
import com.junbao.module.mine.login.model.Login;
import com.junbao.module.mine.login.viewModel.LoginViewModel;

public class LoginActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ActivityLoginBinding binding = DataBindingUtil.setContentView(this, R.layout.activity_login);

        ViewModelProvider provider = new ViewModelProvider(this, new ViewModelProvider.NewInstanceFactory());
        LoginViewModel model = provider.get(LoginViewModel.class);

        model.getUserInfo().observe(this , login->{
            Log.d("liuyi", "onChanged: "+login.getPassword() +"==="+login.getUsername());
            binding.setLogin(login);
        });
    }
}